<?php

namespace quick\admin\library\queue\job;


use quick\admin\library\service\QueueService;
use think\queue\Job;

class HandleServiceJob extends QuickJobBase
{

    protected $service;


    public function setService($service)
    {
        $this->service = $service;
        return $this;
    }

    /**
     * @param Job $job
     * @param array $data
     * @return bool
     * @throws \quick\admin\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function handle($job, $data)
    {

        if (method_exists($this->service, 'handle')) {
            return $this->service->handle($job,$data);
        }

        return true;
    }


    public function queue($later = 0)
    {
        $queue = QueueService::instance()->register('导出任务',$this,$later,[]);
        return $queue;
    }
}